# Encoding: UTF-8

n = 0
shoppingList = []

while True:
    if n >= 5:
        print('商品入库结束！')
        break

    product = input('请输入商品编号商品名称进行商品入库，每次只能输入一件商品：')
    shoppingList.append(product)
    print('商品入库成功！')
    n += 1

for v in shoppingList:
    print('\t', v)

cart = []

while True:
    flag = False
    number = input('请输入要购买的商品编号：')
    if number == 'q':
        print('退出购物！')
        break

    for item in shoppingList:
        if number == item[0:4]:
            cart.insert(0, '1001手机')
            print('商品已成功加入到购物车！')
            flag = True
            break

    if not flag:
        print('您输入的商品编号不存在，请重新输入！')
        continue

print('您购物车选择的商品为：')

for v in cart:
    print('\t', v)


